package models

import "time"

type Order struct {
	Id    int     `json:"id"`
	Name  string  `json:"name"`
	Price float64 `json:"price"`
	Cate  string  `json:"cate"`
}
type order struct {
	Id         int       `json:"id"`
	product_id int       `json:"product_Id"`
	User_name  string    `json:"user_Name"`
	Order_time time.Time `json:"order___time"`
	Quantity   int       `json:"quantity"`
}

func OrderUpload(page, pageSize int) ([]Order, int64, error) {
	var Orders []Order
	var total int64
	if err = DB.Model(&Order{}).Count(&total).Error; err != nil {
		return nil, 0, err
	}
	if err = DB.Model(&Order{}).Offset((page - 1) * pageSize).Limit(pageSize).Find(&Orders).Error; err != nil {
		return nil, 0, err
	}
	return Orders, total, nil
}
